home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / sys / h / dev < prev    next >
Text File  |  1996-11-09  |  3KB  |  104 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/dev,v $
  4.  * $Date: 1996/10/30 21:58:59 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: dev,v $
  10.  * Revision 1.2  1996/10/30 21:58:59  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.1  1996/04/19 21:23:56  simon
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. #ifndef __SYS_DEV_H
  19. #define __SYS_DEV_H
  20.  
  21. #ifndef __UNIXLIB_TYPES_H
  22. #include <unixlib/types.h>
  23. #endif
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. /* This section is placed here to prevent the inclusion of <sys/unix.h>
  30.    and all those other #include files that are otherwise unnecessary.  */
  31. #define MAXFD 64
  32.  
  33. struct file
  34.   {
  35.   __dev_t         dev;        /* device */
  36.   int            oflag;        /* oflag */
  37.   struct file        *dup;        /* dup list */
  38.   __pid_t        pid;        /* pid of owner */
  39.   int            r[6];        /* OS_File r0 -> r5 */
  40.   };
  41.  
  42. #define BADF(f) (!(((f) >= 0 && (f) < MAXFD) ? (__u->file[f].dup) : 0))
  43.  
  44. /* Proper start of <sys/dev.h>.  */
  45.  
  46. #define NDEV        4
  47.  
  48. /* major device numbers */
  49.  
  50. #define DEV_RISCOS    0    /* RiscOS file system */
  51. #define DEV_TTY     1    /* tty */
  52. #define DEV_PIPE    2    /* UnixLib pipe() */
  53. #define DEV_NULL    3    /* /dev/null */
  54.  
  55. struct dev
  56.   {
  57.   int (*open)(char *,int,struct file *);
  58.   int (*close)(int,struct file *);
  59.   int (*read)(int,void *,int,struct file *);
  60.   int (*write)(int,void *,int,struct file *);
  61.   __off_t (*lseek)(int,__off_t,int,struct file *);
  62.   int (*ioctl)(int,int,void *,struct file *);
  63.   };
  64.  
  65. extern struct dev __dev[NDEV];
  66.  
  67. #define major(x) ((x) >> 8)
  68. #define minor(x) ((x) & 0xff)
  69. #define makedev(x,y) (__dev_t)(((x) << 8) | ((y) & 0xff))
  70.  
  71. extern int __fsopen(char *,int,struct file *);
  72. extern int __fsclose(int,struct file *);
  73. extern int __fsread(int,void *,int,struct file *);
  74. extern int __fswrite(int,void *,int,struct file *);
  75. extern __off_t __fslseek(int,__off_t,int,struct file *);
  76. extern int __fsioctl(int,int,void *,struct file *);
  77.  
  78. extern int __ttyopen(char *,int,struct file *);
  79. extern int __ttyclose(int,struct file *);
  80. extern int __ttyread(int,void *,int,struct file *);
  81. extern int __ttywrite(int,void *,int,struct file *);
  82. extern __off_t __ttylseek(int,__off_t,int,struct file *);
  83. extern int __ttyioctl(int,int,void *,struct file *);
  84.  
  85. extern int __pipeopen(char *,int,struct file *);
  86. extern int __pipeclose(int,struct file *);
  87. extern int __piperead(int,void *,int,struct file *);
  88. extern int __pipewrite(int,void *,int,struct file *);
  89. extern __off_t __pipelseek(int,__off_t,int,struct file *);
  90. extern int __pipeioctl(int,int,void *,struct file *);
  91.  
  92. extern int __nullopen(char *,int,struct file *);
  93. extern int __nullclose(int,struct file *);
  94. extern int __nullread(int,void *,int,struct file *);
  95. extern int __nullwrite(int,void *,int,struct file *);
  96. extern __off_t __nulllseek(int,__off_t,int,struct file *);
  97. extern int __nullioctl(int,int,void *,struct file *);
  98.  
  99. #ifdef __cplusplus
  100.     }
  101. #endif
  102.  
  103. #endif
  104.